home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.std.c
- Subject: Re: Are macros expanded within unused macro arguments?
- Date: 01 Feb 1996 17:20:25 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb1102025@qcd.lanl.gov>
- References: <DM3MC3.Atv@scr.siemens.com>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: mlg@scr.siemens.com's message of Thu, 1 Feb 1996 13:19:14 GMT
-
- In article <DM3MC3.Atv@scr.siemens.com> mlg@scr.siemens.com (Michael
- Greenberg) writes:
- <snip>
- Is the following program legal?
-
- #define foo(unused)
- #define bar(x,y)
-
- foo(bar(1))
-
- I read it as being legal.
-
- Excerpt from "6.8.3.1 Argument substitution"
-
- After the arguments for the invocation of a function-like macro have
- been identified, argument substitution takes place. A parameter in the
- replacment list, ..., is replaced by the corresponding argument after
- all macros contained therein have been expanded. Before being
- substituted, each argument's preprocessing tokens are completely macro
- replaced ... .
-
- You gave the reason :-) The quoted text seems to imply the following
- order:
- 1) Identify parameters
- 2) parameters in the replacement list identified
- 3) expansion of the above parameters (if not preceded by # or ## or
- followed by ##)
- 4) substitution
-
- There is a different problem in the quoted text though: it says that
- before substitution, all macros contained in the parameter are
- supposed to be expanded. I do not think that is what is meant though:
- function like macros not followed by ( cannot be expanded according to
- the last sentence: and I guess this is what was meant anyway.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-